package com.bib.ciglog.data;

import com.bib.ciglog.Utils;

public class CigObj {

	public static int REGULAR_CIG = 1;
	public static int E_CIG = 2;

	private int type;
	private long date;


	public CigObj(int type, long date) {
		super();
		this.type = type;
		this.date = date;
	}


	public CigObj() {}


	public int getType() {
		return type;
	}
	public void setType(int type) {
		this.type = type;
	}
	public long getDate() {
		return date;
	}
	public void setDate(long date) {
		this.date = date;
	}


	@Override
	public String toString() {
		String timeLapStr;
		long timeLap = System.currentTimeMillis() - date;
		if (timeLap < 60000){
			timeLapStr = "0 min";
		}else {
			timeLap = timeLap / 60000; // in min

			if (timeLap < 60){
				timeLapStr = Long.toString(timeLap) + " min";
			}else{
				timeLapStr = Long.toString(timeLap/60) + "h" + Long.toString(timeLap%60) + "min"; 
			}

		}


		return Utils.getDate(this) + " : " + (type==REGULAR_CIG?"Cig":"E-cig") + "   " + timeLapStr;
		//		return Utils.getDate(this) + " : " + (type==REGULAR_CIG?"Cig":"E-cig");
	}


	public String toShortString() {
		return Utils.getDate(this) + " : " + (type==REGULAR_CIG?"Cig":"E-cig");
	}


	@Override
	public boolean equals(Object o) {
		return date == ((CigObj)o).getDate();
	}




}
